<?php
$username=$_POST['username'];
$password=$_POST['password'];
$mysqli=mysqli_connect('localhost','root','root','user');
$select="select * from user1 where username='$username'";
//$into="insert into user1 (username,password,datetime,rand) values ('12133','4536463','712311238','2133')";
$obj=mysqli_query($mysqli, $select);
//$arr=mysqli_fetch_assoc($obj);
$arr=mysqli_fetch_row($obj);
$mima=$arr[2];
$rand=$arr[4];
$pass=MD5(MD5($password).$rand);
if(count($arr)>0){
   if ($mima==$pass){
       //登陆成
       $rand1=md5(rand(1000,9999));
       setcookie('token',$rand1,time()+5);
       session_start();
       $_SESSION[$rand1]=$arr[0];

       echo 1;}else{echo 2;}
}else{echo 0;}

   // window.location.href = "/Default.aspx";
   // alert("登录失败");